package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActivityLogs;
import com.ruoyi.system.service.IActivityLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动参与记录管理Controller
 * 
 * @author 墨染
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/system/activityLogs")
public class ActivityLogsController extends BaseController
{
    @Autowired
    private IActivityLogsService activityLogsService;

    /**
     * 查询活动参与记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityLogs activityLogs)
    {
        startPage();
        List<ActivityLogs> list = activityLogsService.selectActivityLogsList(activityLogs);
        return getDataTable(list);
    }

    /**
     * 导出活动参与记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:export')")
    @Log(title = "活动参与记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityLogs activityLogs)
    {
        List<ActivityLogs> list = activityLogsService.selectActivityLogsList(activityLogs);
        ExcelUtil<ActivityLogs> util = new ExcelUtil<ActivityLogs>(ActivityLogs.class);
        util.exportExcel(response, list, "活动参与记录管理数据");
    }

    /**
     * 获取活动参与记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:query')")
    @GetMapping(value = "/{participateId}")
    public AjaxResult getInfo(@PathVariable("participateId") Long participateId)
    {
        return success(activityLogsService.selectActivityLogsByParticipateId(participateId));
    }

    /**
     * 新增活动参与记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:add')")
    @Log(title = "活动参与记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityLogs activityLogs)
    {
        return toAjax(activityLogsService.insertActivityLogs(activityLogs));
    }

    /**
     * 修改活动参与记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:edit')")
    @Log(title = "活动参与记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityLogs activityLogs)
    {
        return toAjax(activityLogsService.updateActivityLogs(activityLogs));
    }

    /**
     * 删除活动参与记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:activityLogs:remove')")
    @Log(title = "活动参与记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{participateIds}")
    public AjaxResult remove(@PathVariable Long[] participateIds)
    {
        return toAjax(activityLogsService.deleteActivityLogsByParticipateIds(participateIds));
    }
}
